package cn.marinda.totipotentwar.global;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.ArrayList;
import java.util.List;

public class GameGui extends AbstractGui{

    /**
     * 游戏界面
     */
    public GameGui(){
        super(9*5,"game","§6[游戏界面]");
        defaultSetting();
    }
    /**
     * 默认设置
     */
    @Override
    public void defaultSetting() {
        //19 Slot
        Inventory game = this.getInventory();
        ItemStack startGameItem = new ItemStack(Material.NETHER_STAR,1);
        ItemMeta meta  = startGameItem.getItemMeta();
        meta.setDisplayName("§b开始游戏");
        List<String> lore = new ArrayList();
        lore.add("§a\t 点我开始匹配！");
        meta.setLore(lore);
        startGameItem.setItemMeta(meta);
        game.setItem(19,startGameItem);

        //22 Slot JoinGame
        ItemStack joinGames = new ItemStack(Material.SKULL_ITEM);
        ItemMeta joinItemMeta = joinGames.getItemMeta();
        List<String> joinLores=  new ArrayList<>();
        joinLores.add("§a\t 点我加入游戏。");
        joinLores.add("§c若未开启游戏则无法进入。");
        joinItemMeta.setDisplayName("§e加入游戏");
        joinItemMeta.setLore(joinLores);
        joinGames.setItemMeta(joinItemMeta);

        game.setItem(22,joinGames);

        // 25 Slot LeaveGame
        ItemStack leaveGame = new ItemStack(Material.SLIME_BALL);
        ItemMeta leaveMeta = leaveGame.getItemMeta();
        leaveMeta.setDisplayName("§b离开游戏");
        List<String> leaveLores = new ArrayList<>();
        leaveLores.add("§6\t 点我离开游戏。");
        leaveLores.add("§c退出游戏。");
        leaveMeta.setLore(leaveLores);
        leaveGame.setItemMeta(leaveMeta);
        game.setItem(25,leaveGame);
    }

    /**
     * 开放的库存
     *
     * @param player 球员
     */
    @Override
    public void openInventory(Player player) {
        player.closeInventory();
        player.openInventory(this.getInventory());
    }
}
